#pragma once

#include <jsi/jsi.h>

#include <memory>
#include <optional>
#include <string>

#include "ModuleRegistry.h"

using namespace facebook::jsi;

namespace jsiexecutor {

class JSINativeModules {
 public:
  explicit JSINativeModules(std::shared_ptr<ModuleRegistry> moduleRegistry);
  Value getModule(Runtime& rt, const PropNameID& name);
  void reset();

 private:
  std::shared_ptr<ModuleRegistry> moduleRegistry_;
  std::unordered_map<std::string, Object> objects_;
  std::optional<Function> genNativeModule_;
  std::optional<Object> createModule(Runtime& rt, const std::string& name);
};

}  // namespace jsiexecutor
